/* GUI CONVERTED from rcmbmt.p (converter v1.76) Thu Jul  4 11:42:24 2002 */
/* rcmbmt.p - MASTER BILL MAINTENANCE                                         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.9.1.12 $                                                       */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.5      LAST MODIFIED: 03/20/95   BY: GWM *J049*                */
/* REVISION: 8.5      LAST MODIFIED: 04/23/96   BY: GWM *J0K1*                */
/* REVISION: 8.5      LAST MODIFIED: 05/31/96   BY: RUW *J0NW*                */
/* REVISION: 8.5      LAST MODIFIED: 06/11/96   BY: rxm *G1XQ*                */
/* REVISION: 8.5      LAST MODIFIED: 07/11/96   BY: ame *J0YS*                */
/* REVISION: 8.6      LAST MODIFIED: 08/08/96   BY: *K003* Vinay Nayak-Sujir  */
/* REVISION: 8.6      LAST MODIFIED: 12/06/96   BY: *K030* Vinay Nayak-Sujir  */
/* REVISION: 8.6      LAST MODIFIED: 01/28/97   BY: *K059* Kieu Nguyen        */
/* REVISION: 8.6      LAST MODIFIED: 03/20/97   BY: *J1LM* Ajit Deodhar       */
/* REVISION: 8.6      LAST MODIFIED: 04/15/97   BY: *K08N* Steve Goeke        */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* Revision: 1.9.1.3     BY: Jean Miller      DATE: 03/22/01 ECO: *P008*      */
/* Revision: 1.9.1.6     BY: Reetu Kapoor     DATE: 05/18/01 ECO: *M17X*      */
/* Revision: 1.9.1.7     BY: Veena Lad   DATE: 12/24/01 ECO: *P03W*      */
/* $Revision: 1.9.1.12 $        BY: R.Satya Narayan      DATE: 06/25/02  ECO: *P086* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/* ********** Begin Translatable Strings Definitions ********* */

{mfdtitle.i "2+ "} /*GUI moved to top.*/
&SCOPED-DEFINE rcmbmt_p_1 "Ship-From"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmt_p_2 "Ship-To/Dock"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmt_p_3 "Comments"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmt_p_4 "Master Bill"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcmbmt_p_5 "Multi"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

/*GUI moved mfdeclre/mfdtitle.*/

/* SHARED VARIABLES FOR OLD CODE CALL COMPATABILITY */
define new shared variable cmtindx like cmt_indx.
define new shared variable abs_recid as recid.
define shared variable global_recid as recid.

/* LOCAL VARIABLES */
define variable disp_abs_id    like abs_id no-undo.
define variable del-yn         like mfc_logical no-undo.
define variable cmmts          like mfc_logical label {&rcmbmt_p_3} no-undo.
define variable shipgrp        like sg_grp no-undo.
define variable nrseq          like shc_ship_nr_id no-undo.
define variable inv_mov        like im_inv_mov no-undo.
define variable errorst        like mfc_logical no-undo.
define variable errornum       as integer no-undo.
define variable is_valid       like mfc_logical no-undo.
define variable is_internal    like mfc_logical no-undo.
define variable can_discard    like mfc_logical no-undo.
define variable multi_carrier  like mfc_logical no-undo.
define variable multi_entry    like mfc_logical label {&rcmbmt_p_5} no-undo.
define variable carrier        like absc_carrier no-undo.
define variable v_old_format   like abs_format no-undo.
define variable msgnbr         as   integer.
define variable dummy-length   as   character format "999:99".


define variable shp_time as character format "xx:xx" no-undo initial  "0000".
define variable arr_time as character format "xx:xx" no-undo initial  "0000".
/* BUFFERS */
define buffer abs_temp for abs_mstr.

/* FROZEN SCHEMA VARIABLES */
{rcmbrpa.i}


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
abs_shipfrom         colon 25 label {&rcmbmt_p_1}
   si_desc              at 37 no-label
   abs_id               colon 25 label {&rcmbmt_p_4}
   abs_shipto           colon 25 label {&rcmbmt_p_2}
   ad_name              at 37 no-label
   ad_line1             at 37 no-label
   shipgrp              colon 25
   sg_desc              at 37 no-label
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
carrier              colon 25
   multi_entry          colon 42
   abs_format           colon 68
   abs_shipvia          colon 25
   abs_fob              colon 25
   abs_trans_mode       colon 25
   abs_carr_ref         colon 25
   abs_lang             colon 68
   abs_veh_ref          colon 25
   abs_shp_date         colon 25
   shp_time             colon 25 label "Ship Time"
   abs_arr_date         colon 25 label "Arrive Date"
   arr_time             colon 25 label "Arrival Time"
   cmmts                colon 68
 SKIP(.4)  /*GUI*/
with frame c width 80 attr-space side-labels NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-c-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame c = F-c-title.
 RECT-FRAME-LABEL:HIDDEN in frame c = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame c =
  FRAME c:HEIGHT-PIXELS - RECT-FRAME:Y in frame c - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME c = FRAME c:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame c:handle).

/* DEFAULT FROM GLOBAL IF EXISTS */
find abs_mstr where recid(abs_mstr) = global_recid no-lock no-error.

if available abs_mstr
   and (abs_id begins "M" and abs_type = "S")
then do:

   find si_mstr where si_site = abs_shipfrom no-lock no-error.

   display
      abs_shipfrom
      si_desc when (available si_mstr)
      trim(substring(abs_id,2)) @ abs_id
   with frame a.

end.

/* CHECK EXISTENCE OF CONTROL RECORD FOR NEXT NUMBER */
{gprun.i ""rcpma.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


{gprun.i ""socrshc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


 find first shc_ctrl no-lock.

mainloop:
repeat with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.


   /* GET SHIPFROM AND ID */
   prompt-for
      abs_shipfrom
      abs_id
      abs_shipto
   editing:

      global_site = input abs_shipfrom.

      /* FIELD = ABS_SHIPFROM */
      if frame-field = "abs_shipfrom" then do:

         {mfnp05.i abs_mstr abs_id
            "abs_id begins 'M'"
            abs_shipfrom
            "input abs_shipfrom"}

         if recno <> ? then do:

            find si_mstr
            where si_site = abs_shipfrom no-lock no-error.

            /* Get Shipping Group */
            {gprun.i ""gpgetgrp.p""
               "(input abs_shipfrom,
                 input abs_shipto,
                 output shipgrp)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            shipgrp = if shipgrp = ? then
                         ""
                      else
                         shipgrp.

            find sg_mstr where sg_grp = shipgrp no-lock no-error.

            disp_abs_id = trim(substring(abs_id,2,50)).

            display
               abs_shipfrom
               abs_shipto
               si_desc
                  when (available si_mstr)
               ""
                  when (not available si_mstr) @ si_desc
               disp_abs_id @ abs_id
               shipgrp
               (if not available sg_mstr then ""
                else sg_desc) @ sg_desc.

         end.

      end. /* IF FRAME-FIELD = ABS_SHIPFROM */

      /* FIELD = ABS_ID */
      else
      if frame-field = "abs_id" then do:

         {mfnp05.i abs_mstr abs_id
            "abs_shipfrom = input abs_shipfrom
                     and abs_id begins 'M'"
            abs_id
            "'M' + input abs_id"}

         if recno <> ? then do:
            find si_mstr
            where si_site = abs_shipfrom no-lock no-error.

            disp_abs_id = trim(substring(abs_id,2)).

            {gprun.i ""gpgetgrp.p""
               "(input abs_shipfrom,
                 input abs_shipto,
                 output shipgrp)"}
/*GUI*/ if global-beam-me-up then undo, leave.


            shipgrp = if shipgrp = ? then
                         ""
                      else
                         shipgrp.

            find sg_mstr where sg_grp = shipgrp no-lock no-error.

            display
               abs_shipfrom
               abs_shipto
               si_desc
                  when (available si_mstr)
               ""
                  when (not available si_mstr)@ si_desc
               disp_abs_id @ abs_id
               shipgrp
               (if not available sg_mstr then ""
                else sg_desc) @ sg_desc.
         end.

      end. /* IF FRAME-FIELD = ABS_ID */

      else do:
         status input.
         readkey.
         apply lastkey.
      end.

   end. /* EDITING */

   find si_mstr where si_site = input abs_shipfrom
   no-lock no-error.

   if not available si_mstr then do:
      /* SITE DOES NOT EXIST */
      {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}
      next-prompt abs_shipfrom.
      undo, retry.
   end.

   display
      si_desc.

   /* Check Site Security */
   {gprun.i ""gpsiver.p""
      "(input si_site, input recno, output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

   if return_int = 0 then do:
      /* User does not have access to this site */
      {pxmsg.i &MSGNUM=725 &ERRORLEVEL=3}
      next-prompt abs_shipfrom with frame a.
      undo mainloop, retry mainloop.
   end.

   /* GET THE NEXT MASTER BILL NUMBER */
   /* Find the shipping group for the shipfrom-shipto combination */
   {gprun.i ""gpgetgrp.p""
      "(input frame a abs_shipfrom,
        input frame a abs_shipto,
        output shipgrp)"}
/*GUI*/ if global-beam-me-up then undo, leave.


   shipgrp = if shipgrp = ? then
                ""
             else
                shipgrp.

   find sg_mstr where sg_grp = shipgrp no-lock no-error.

   display
      shipgrp
      (if not available sg_mstr then ""
       else sg_desc) @ sg_desc with frame a.

   do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


      find abs_mstr where
           abs_shipfrom = input frame a abs_shipfrom
       and abs_id = "M" + input frame a abs_id
      exclusive-lock no-error.

      if locked(abs_mstr) then do:
         /* RECORD LOCKED - TRY AGAIN LATER */
         {pxmsg.i &MSGNUM=7422 &ERRORLEVEL=3}
         undo mainloop, retry mainloop.
      end.

      if not available abs_mstr then do:

         nrseq = if available sg_mstr then
                    sg_master_nr_id
                 else
                    shc_master_nr_id.

         if not can-find(first ad_mstr where
                               ad_addr = input frame a abs_shipfrom)
         then do:
            /* SITE ADDRESS DOES NOT EXIST */
            {pxmsg.i &MSGNUM=864 &ERRORLEVEL=3}
            next-prompt abs_shipfrom.
            undo mainloop, retry mainloop.
         end.

         /* Number generation/validation logic using NRM functionality*/
         run chk_internal
            (input nrseq,
             output is_internal,
             output errorst,
             output errornum).

         if errorst then do:
            {pxmsg.i &MSGNUM=errornum &ERRORLEVEL=3}
            next-prompt abs_id with frame a.
            undo mainloop, retry mainloop.
         end.

         if is_internal then do:
            if not available abs_mstr and
               input frame a abs_id <> ""
            then do:
               /* MASTER BILL DOES NOT EXIST */
               {pxmsg.i &MSGNUM=5937 &ERRORLEVEL=3}
               next-prompt abs_id with frame a.
               undo mainloop, retry mainloop.
            end.
         end.
         else do: /* external sequence */
            if input frame a abs_id = "" then do:
               /* MASTER BILL NUMBER MUST BE ENTERED */
               {pxmsg.i &MSGNUM=5932 &ERRORLEVEL=3}
               next-prompt abs_id with frame a.
               undo mainloop, retry mainloop.
            end.
            else do:
               /* Validate that the number entered conforms to the sequence */
               run valnbr
                  (input nrseq,
                   input today,
                   input frame a abs_id,
                   output is_valid,
                   output errorst,
                   output errornum).
               if not is_valid then do:
                  if errorst then do:
                     {pxmsg.i &MSGNUM=errornum &ERRORLEVEL=3}
                  end.
                  /* INVALID MASTER BILL NUMBER FORMAT */
                  {pxmsg.i &MSGNUM=5952 &ERRORLEVEL=3}
                  next-prompt abs_id with frame a.
                  undo mainloop, retry mainloop.
               end.
            end.
         end. /* external seq */

         {pxmsg.i &MSGNUM=1 &ERRORLEVEL=1} /* ADDING NEW RECORD */

         create abs_mstr.
         /* Fetch the next available number from the sequence */
         if is_internal then do:
            run getnbr
               (input nrseq,
                input today,
                output abs_id,
                output errorst,
                output errornum).
            if errorst = true then do:
               {pxmsg.i &MSGNUM=errornum &ERRORLEVEL=3}
               undo mainloop, retry mainloop.
            end.
            display
               abs_id
            with frame a.
         end.

         find ad_mstr where
            ad_addr = input frame a abs_shipto
         no-lock no-error.

         assign
            abs_shipfrom = input frame a abs_shipfrom
            abs_id = "M" + input frame a abs_id
            abs_qty = 1
            abs_type = "S"
            abs_shipto = input frame a abs_shipto
            abs_nr_id = nrseq

            abs_dataset = "sod_det".

         /* Get the default language */
         {gprun.i ""icshlng.p"" "(recid(abs_mstr), output abs_lang)" }
/*GUI*/ if global-beam-me-up then undo, leave.


         find mfc_ctrl no-lock where
              mfc_field = "rcc_mbol_format" no-error.
         assign
            abs_format   = if available mfc_ctrl then mfc_char else ""
            v_old_format = "".

      end. /* IF NOT AVAILABLE ABS_MSTR */

      else
         v_old_format = abs_format.

      if abs_shipto <> input frame a abs_shipto and
         input frame a abs_shipto <> ""
      then do:
         /* SHIP-TO FIELD OVERWRITTEN WITH SHIP-TO FOR SHIPPER */
         {pxmsg.i &MSGNUM=5965 &ERRORLEVEL=2}
      end.

      display
         abs_shipto
      with frame a.

      global_recid = recid(abs_mstr).

      display
         abs_shipto
         ad_name when (available ad_mstr)
         ad_line1 when (available ad_mstr)
      with frame a.

      /* REDUCE THE TRANSACTION SCOPE SO THAT THE nr_mstr RECORD IS  */
      /* RELEASED ONCE THE MASTER BILL OF LADING NUMBER IS GENERATED */
      /* ALSO RELEASING abs_mstr BEFORE EACH TRANSACTION ENDS        */

      release abs_mstr.
   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* DO TRANSACTION */

   do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


      find first abs_mstr
         where abs_shipfrom = input frame a abs_shipfrom
           and abs_id       = "M" + input frame a abs_id
      exclusive-lock no-error.

      /* The complex can-find translates as "can find one and only
       * one absc_det record for the given abs_id" */
      assign
         shp_time = trim(substring(string(abs_shp_time,"hh:mm"),1,2))
                   + trim(substring(string(abs_shp_time,"hh:mm"),4,2))
         arr_time = trim(substring(string(abs_arr_time,"hh:mm"),1,2))
                   + trim(substring(string(abs_arr_time,"hh:mm"),4,2))
         abs_shipvia    = trim(substring(abs__qad01,1,20))
         abs_fob        = trim(substring(abs__qad01,21,20))
         abs_carr_ref   = trim(substring(abs__qad01,41,20))
         abs_trans_mode = trim(substring(abs__qad01,61,20))
         abs_veh_ref    = trim(substring(abs__qad01,81,20))
         multi_entry    = can-find (first absc_det where
                                       absc_abs_id = abs_id) and
                          not can-find (absc_det where
                                        absc_abs_id = abs_id)
         multi_carrier  = multi_entry
         cmmts          = abs_cmtindx > 0.

         if shp_time = ? or shp_time = "?" then shp_time = "0000".
         if arr_time = ? or arr_time = "?" then arr_time = "0000".
      find first absc_det where
                 absc_abs_id = abs_id
      no-lock no-error.

      if available absc_det then
         carrier = absc_carrier.

      display
         carrier
         multi_entry
         abs_format
         abs_shipvia
         abs_fob
         abs_trans_mode
         abs_carr_ref
         abs_veh_ref
         abs_shp_date
         shp_time
         abs_arr_date
         arr_time
         abs_lang
         cmmts
      with frame c.

      hdr_blk:
      do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


         ststatus = stline[2].
         status input ststatus.

         set
            carrier when (not multi_carrier)
            multi_entry
            abs_shipvia
            abs_fob
            abs_trans_mode
            abs_carr_ref
            abs_veh_ref
            abs_shp_date
            shp_time
            abs_arr_date
            arr_time
            abs_format
            abs_lang
            cmmts
            go-on(F5 CTRL-D)
            with frame c.

         /* EDIT USER INPUT TIME FIELDS */
         {gprun.i ""fstimchk.p""
            "(input         ""T"",
              input         shp_time,
              input         """",
              output        shp_time,
              output        dummy-length,
              output        msgnbr)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         /* FSTIMCHK WILL RETURN ONE OF TWO POTENTIAL  */
         /* ERRORS.  #30 IS FOR MINUTES > 59.  #69     */
         /* INDICATES NON-NUMERIC INPUT, IN WHICH CASE */
         /* WE WANT TO PRESERVE AND REDISPLAY THE USER */
         /* INPUT.                                     */
         if msgnbr <> 0 then do:
           {pxmsg.i &MSGNUM=msgnbr &ERRORLEVEL=3}
           next-prompt shp_time with frame c.
           undo,retry.
         end.

         /* EDIT USER INPUT TIME FIELDS */
         {gprun.i ""fstimchk.p""
            "(input         ""T"",
              input         arr_time,
              input         """",
              output        arr_time,
              output        dummy-length,
              output        msgnbr)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         /* FSTIMCHK WILL RETURN ONE OF TWO POTENTIAL  */
         /* ERRORS.  #30 IS FOR MINUTES > 59.  #69     */
         /* INDICATES NON-NUMERIC INPUT, IN WHICH CASE */
         /* WE WANT TO PRESERVE AND REDISPLAY THE USER */
         /* INPUT.                                     */

         if msgnbr <> 0 then do:
            {pxmsg.i &MSGNUM=msgnbr &ERRORLEVEL=3}
            next-prompt arr_time with frame c.
            undo,retry.
         end.
         if lastkey = keycode("F5")
         or lastkey = keycode("CTRL-D") then do:

            if abs_nr_id <> "" then do:

               run chk_delnbr
                  (input abs_nr_id,
                   output can_discard,
                   output errorst,
                   output errornum).

               if errorst then do:
                  {pxmsg.i &MSGNUM=errornum &ERRORLEVEL=3}
                  undo hdr_blk, retry hdr_blk.
               end.

               if not can_discard then do:
                  /* DELETION PROHIBITED, GAPS IN SEQUENCE NOT PERMITTED */
                  {pxmsg.i &MSGNUM=5945 &ERRORLEVEL=3}
                  undo hdr_blk, retry hdr_blk.
               end.

            end.

            del-yn = yes.

            /* Please confirm delete */
            {pxmsg.i &MSGNUM=11 &ERRORLEVEL=1 &CONFIRM=del-yn
                     &CONFIRM-TYPE='LOGICAL'}

            if del-yn = no
               then undo hdr_blk, retry hdr_blk.

            for each abs_temp
               where abs_temp.abs_master_id = abs_mstr.abs_id
            exclusive-lock:
               abs_temp.abs_master_id = "".
            end.

            for each absc_det where absc_abs_id = abs_mstr.abs_id
            exclusive-lock:
               delete absc_det.
            end.

            /* Delete comments */
            for each cmt_det exclusive-lock where cmt_indx = abs_cmtindx:
               delete cmt_det.
            end.  /* for each cmt_det */

            /* Delete trailer comments */
            for each cmt_det exclusive-lock where
                     cmt_indx = abs_trl_cmtindx:
               delete cmt_det.
            end.  /* for each cmt_det */

            delete abs_mstr.

            hide frame b no-pause.
            clear frame a no-pause.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
            next mainloop.

         end. /* IF LASTKEY = DELETE */

         if integer(substring(shp_time,1,2)) > 24 then do:
            /*HOURS MUST BE BETWEEN 00 AND 24*/
            {pxmsg.i &MSGNUM=29 &ERRORLEVEL=3}
            next-prompt shp_time with frame c.
            undo hdr_blk, retry hdr_blk.
         end.

         if integer(substring(shp_time,3,2)) > 60 then do:
            /*MINUTES MUST BE BETWEEN 00 AND 60*/
            {pxmsg.i &MSGNUM=30 &ERRORLEVEL=3}
            next-prompt shp_time with frame c.
            undo hdr_blk, retry hdr_blk.
         end.

         if integer(substring(arr_time,1,2)) > 24 then do:
            /*HOURS MUST BE BETWEEN 00 AND 24*/
            {pxmsg.i &MSGNUM=29 &ERRORLEVEL=3}
            next-prompt arr_time with frame c.
            undo hdr_blk, retry hdr_blk.
         end.

         if integer(substring(arr_time,3,2)) > 60 then do:
            /*MINUTES MUST BE BETWEEN 00 AND 60*/
            {pxmsg.i &MSGNUM=30 &ERRORLEVEL=3}
            next-prompt arr_time with frame c.
            undo hdr_blk, retry hdr_blk.
         end.

         /* Validate that format exists */
         if abs_format <> "" then do:
            find df_mstr where
                 df_type   = "2" and
                 df_format = abs_format
            no-lock no-error.
            if not available df_mstr then do:
               /* Document format not found */
               {pxmsg.i &MSGNUM=5900 &ERRORLEVEL=3}
               next-prompt abs_format with frame c.
               undo hdr_blk, retry hdr_blk.
            end.  /* if not available */
         end.  /* if abs_format */

         assign
            abs_shp_time = ((integer(substring(shp_time,1,2)) * 60)
                           + integer(substring(shp_time,3,2))) * 60
            abs_arr_time = ((integer(substring(arr_time,1,2)) * 60)
                           + integer(substring(arr_time,3,2))) * 60
            abs__qad01 = string(abs_shipvia,"x(20)")
                         + string(abs_fob,"x(20)")
                         + string(abs_carr_ref,"x(20)")
                         + string(abs_trans_mode,"x(20)")
                         + string(abs_veh_ref,"x(20)").

         if not (can-find (lng_mstr where
                           lng_lang = abs_lang))
         then do:
            /* LANGUAGE MUST EXIST */
            {pxmsg.i &MSGNUM=5050 &ERRORLEVEL=3}
            next-prompt abs_lang with frame c.
            undo hdr_blk, retry hdr_blk.
         end.

         /* CARRIERS */
         if carrier <> "" then do:
            if not can-find (first ad_mstr where
                                   ad_addr = carrier)
            then do:
               /* ADDRESS DOES NOT EXIST  */
               {pxmsg.i &MSGNUM=980 &ERRORLEVEL=3}
               next-prompt carrier with frame c.
               undo hdr_blk, retry hdr_blk.
            end.

            if not can-find (first ls_mstr where
                                   ls_addr = carrier and
                                   ls_type = "carrier" )
            then do:
               /* ADDRESS IS NOT OF TYPE "CARRIER" */
               {pxmsg.i &MSGNUM=5905 &ERRORLEVEL=3}
               next-prompt carrier with frame c.
               undo hdr_blk, retry hdr_blk.
            end. /* not can-find ls_mstr  */

            find first absc_det where
               absc_abs_id = abs_id
            exclusive-lock no-error.
            if not available absc_det then do:
               create absc_det.
               assign
                  absc_abs_id = abs_id
                  absc_seq = 1.
            end.
            assign
               absc_carrier = carrier.
         end. /* if carrier <> "" */

         /* Warn about changing format if already printed */
         if v_old_format <> abs_format and
            v_old_format <> ""         and
            trim(substring(abs_status,1,1)) = "y"
         then do:
            /* Master bill has already been printed */
            {pxmsg.i &MSGNUM=5821 &ERRORLEVEL=2}
         end.  /* if v_old_format */

         /* Warn about blank format */
         else if abs_format = "" then do:
            /* Format is blank, document will not be printed */
            {pxmsg.i &MSGNUM=5817 &ERRORLEVEL=2}
         end.  /* else if abs_format */

         /* VALIDATE SHIPVIA */
         if not ({gpcode.v abs_shipvia abs_shipvia})
         then do:
            /* VALUE MUST EXIST IN GENERALIZED CODES */
            {pxmsg.i &MSGNUM=716 &ERRORLEVEL=3}
            next-prompt abs_shipvia with frame c.
            undo hdr_blk, retry hdr_blk.
         end. /* IF NOT ({gpcode.v ...}) */

         /* If multi-entry then display/update more carriers */
         if multi_entry then do:
            {gprun.i ""rcshwcar.p"" "(input abs_id, 6)"}
/*GUI*/ if global-beam-me-up then undo, leave.

         end.

         /* HANDLE COMMENTS */

         if cmmts then do:
            cmtindx = abs_mstr.abs_cmtindx.
            global_ref = abs_mstr.abs_shipto.
            {gprun.i ""gpcmmt01.p"" "(input 'abs_mstr')"}
/*GUI*/ if global-beam-me-up then undo, leave.

            abs_mstr.abs_cmtindx = cmtindx.
         end.

      end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* hdr_blk */

      abs_recid = recid(abs_mstr).

      hide frame a no-pause.
      hide frame b no-pause.
      hide frame c no-pause.

      /* MASTER BILL MAINTENANCE */

      {gprun.i ""rcmbmta.p"" "(input abs_recid)" }
/*GUI*/ if global-beam-me-up then undo, leave.


      view frame a.

      /* Print master bill of lading */
      {gprun.i ""icmbprt.p"" "(abs_recid)" }
/*GUI*/ if global-beam-me-up then undo, leave.


      release abs_mstr.
   end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* DO TRANSACTION */

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* mainloop */

{rcshhdr.i}
{gpnrseq.i}
